import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';

import { Observable, of } from 'rxjs';
import { Project } from '@/app/types/iworkflow/Project';
import { DataRenderColumn } from '@/app/types/Core';

@Component({
  selector: 'app-welcome',
  templateUrl: './welcome.component.html',
  styleUrls: ['./welcome.component.less']
})
export class WelcomeComponent implements OnInit {

  projects: Project[] = [];

  columns: DataRenderColumn[] = [
    { title: '编号', dataIndex: 'ID', width: 80 },
    { title: '项目SN', dataIndex: 'ProjectSN', width: 80 },
    { title: '项目名称', dataIndex: 'ProjectName', width: 80 },
    { title: '公司名称', dataIndex: 'CompanyName', width: 80 },
    { title: 'SAP编码', dataIndex: 'SAPCode', width: 80 },
    { title: '状态', dataIndex: 'IsActive', width: 80 },
    { title: 'BU', dataIndex: 'BU', width: 80 }
  ];

  constructor (private httpClient: HttpClient) {
  }

  ngOnInit() {
    this.httpClient.get('/api/Project/GetAllProjectsForLeo').subscribe((rs: any) => {
      this.projects = rs.data as Project[];
    });
  }

  alert(info: string) {
    window.alert(info);
  }
}
